<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ page contentType="text/html; charset=UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/Css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/Css/bootstrap-responsive.css"/>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/Css/style.css"/>
    <link href="<%=request.getContextPath()%>/Css/jquery-ui.min.css"
          type="text/css" rel="stylesheet"/>
    <link rel="stylesheet" type="text/css"
          href="<%=request.getContextPath()%>/Css/kkpager/kkpager_blue.css"/>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery2.js"></script>
    <%--  <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery2.sorted.js"></script> --%>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/bootstrap.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/ckform.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/common.js"></script>
    <script type="text/javascript"
            src="<%=request.getContextPath()%>/js/jquery-ui.min.js"></script>

</head>
<body>
<form id="agentform" class="form-inline definewidth m20" action="/" method="post">

    <label><span>代理商ID：</span><input type="text" name="id" id="id" class="abc input-default"
                                     value="${userId}">&nbsp;&nbsp;
    </label>
    <button type="button" class="btn btn-primary" onclick="queryAgentCoin();">查询</button>
</form>
<table class="table table-bordered table-hover definewidth m10">
    <thead>
    <tr>
        <th>代理商id</th>
        <th>代理商名称</th>
        <th>代理商帐号</th>
        <th>财富值</th>
        <th>账户操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${page.data}" var="manager">
        <tr>
            <td name="id">${manager.id}</td>
            <td name="userAccount">${manager.userAccount}</td>
            <td name="userName">${manager.userName}</td>
            <td name="agentCoin">${manager.agentCoin}</td>
            <td><a href="#" onclick="showCionDiv(${manager.id},'${manager.userAccount}',this)" class="btn btn-primary">加钻</a>
            </td>
        </tr>
    </c:forEach>
    </tbody>
    <tfoot>
    <tr bgcolor="EEF7FE">
        <td colspan="14" bgcolor="EEF7FE" class="f">
            <div align="right" style="bgcolor:EEF7FE" class="f">
                <jsp:include page="/common/pageUtil.jsp"></jsp:include>
            </div>
        </td>
    </tr>
    </tfoot>
</table>
<div style="padding-left:0px;padding-right:50px;" id="kkpager"></div>
<div id="addCoinDiv" style="display: none;">
    <form action="/" method="post" id="addCoinForm">
        <!-- <input id="user_id" name="user_id" type='hidden'  value=""/> -->
        <table cellpadding="0" cellspacing="0">
            <tr>

                <td><label for="user_id"><span
                        style="color:#F00; margin-right:2px;">*</span>代理ID：
                </label>
                </td>
                <td><input id="user_id" name="user_id" type='text' class="sp_t"
                           value="" readonly="readonly"/></td>
            </tr>

            <tr>
                <td><label for="mahjong_coin"><span
                        style="color:#F00; margin-right:2px;">*</span>钻石：
                </label>
                </td>
                <td><input id="mahjong_coin" name="mahjong_coin" type='text' class="sp_t"
                           value=""/></td>
            </tr>
        </table>
    </form>

</div>


</body>


<script type="text/javascript">
    // 下一页
    function getNextPage(page) {
        var form = document.getElementById("agentform");
        form.action = "<%=request.getContextPath()%>/agent/agentCoinOperate.html?pageIndex=" + page;
        form.submit();
    }

    function queryAgentCoin() {

        var form = document.getElementById("agentform");
        form.action = "<%=request.getContextPath()%>/agent/agentCoinOperate.html";
        form.submit();

    }

    //加砖div
    function showCionDiv(id, account, obj) {
        $("#user_id").val(id);
        //$("#agent_id").val(account)
        $("#addCoinDiv").dialog({
            title: "加砖",
            height: 300,
            width: 500,
            modal: true,
            open: function (event, ui) {
                $(".ui-dialog-titlebar-close", $(this).parent()).hide();
            },
            buttons: {
                "确定": function () {
                    if (confirm("确认充值？")) {
                        addCoin(obj, $(this));
                    }

                },
                "取消": function () {
                    resetAll();
                    $(this).dialog("close");
                }
            }
        });
    }


    function addCoin(obj, obj1) {
        var parent = $(obj).parent().parent();

        $.ajax({
            type: "POST",
            url: "<%=request.getContextPath()%>/agent/agentCoinAdd.html",
            data: {
                "orderUser": $("#user_id").val(),
                "tradeCoin": $("#mahjong_coin").val(),

            },
            dataType: 'json',
            success: function (data) {
                /*var row=data.effectRow;
                 if(row>0){
                 $(parent).find("td[name='mahjongCoin']").text(data.coinModel.mahjongCoin);
                 }*/
                 var id=$("#agentform").find("#id").val();
                 var form = document.getElementById("agentform");
                 form.action = "<%=request.getContextPath()%>/agent/agentCoinOperate.html";
                 form.submit();
                resetAll();
                $(obj1).dialog("close");
            }
        });
    }

    function resetAll() {

        var myform = document.getElementById("addCoinForm");
        myform.reset();
    }

</script>

</html>